<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>获取 Apache subprocess_env 变量</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.apache-getenv" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">apache_getenv</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.3.0, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">apache_getenv</span> &mdash; <span class="dc-title">获取 Apache subprocess_env 变量</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.apache-getenv-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>apache_getenv</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$variable</code></span>
   [, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$walk_to_top</code><span class="initializer"> = false</span></span>
  ] ) : <span class="type">string</span></div>

  <p class="para rdfs-comment">
   获取 <code class="parameter">variable</code> 指定的环境变量。
  </p>
  <p class="para">
   此函数需要 Apache 2 否则为 undefined。 
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.apache-getenv-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">variable</code></dt>

     <dd>

      <p class="para">
       Apache 环境变量
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">walk_to_top</code></dt>

     <dd>

      <p class="para">
       是否获取对Apache各层可用的顶层变量
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.apache-getenv-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 Apache 环境变量值，失败时返回 <strong><code>FALSE</code></strong> 
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.apache-getenv-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-5816">
    <p><strong>Example #1 <span class="function"><strong>apache_getenv()</strong></span> example</strong></p>
    <div class="example-contents"><p>
     该示例显示如何取得 Apache 环境变量
     <var class="varname"><var class="varname">SERVER_ADDR</var></var>的值。
    </p></div>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$ret&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">apache_getenv</span><span style="color: #007700">(</span><span style="color: #DD0000">"SERVER_ADDR"</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #0000BB">$ret</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

    <div class="example-contents"><p>以上例程的输出类似于：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
42.24.42.240
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.apache-getenv-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="apache_setenv.html" class="function" rel="rdfs-seeAlso">apache_setenv()</a> - 设置 Apache 子进程环境变量</span></li>
    <li class="member"><span class="function"><a href="getenv.html" class="function" rel="rdfs-seeAlso">getenv()</a> - 获取一个环境变量的值</span></li>
    <li class="member"><a href="language.variables.superglobals.html" class="link">Superglobals</a></li>
   </ul>
  </p>
 </div>

</div></div></div></body></html>